<template>

    <h3>我的订单</h3>
    <el-table :data="cutObj.records" style="width: 100%" border="1">
      <el-table-column prop="id" label="订单号"  />
      <el-table-column prop="totalPrice" label="订单总价" />
      <el-table-column prop="status" label="订单状态" />
      <el-table-column prop="orderDate" label="下单时间" />
      <el-table-column fixed="right" label="订单详情" width="">
        <template #default="scope">
          <el-button link type="primary" size="small" @click="gotoOrderDetail(scope.row)">查看详情</el-button>
        </template>
      </el-table-column>
    </el-table>

  <el-pagination
      v-model:current-page="cutObj.current"
      v-model:page-size="cutObj.size"
      background
      layout="prev, pager, next, jumper"
      :total="cutObj.total"
      @current-change="findByItem"
  />


</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      cutObj:{}
    }
  },
  methods:{
  findByItem(pageNO){
    let  userId=sessionStorage.getItem("userId");
    axios.get("/project/order/findByItem",{params:{pageNO,userId}}).then(resp=> {

      if(resp.data == "noLogin"){
        console.log(resp.data)
        this.$router.push('/shopLogin')
      }
      this.cutObj = resp.data;
    });
  },gotoOrderDetail(orderObj){
      //封装
      sessionStorage.setItem("id",orderObj.id);
      //跳转
      this.$router.push('/orderDetail')
    }
  },created() {
    this.findByItem(1);
  }
}
</script>

<style scoped>

</style>